package org.kjtc.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.kjtc.entity.Page;
import org.kjtc.entity.Role;
import org.kjtc.entity.UserRole;
import org.springframework.stereotype.Service;

@Service("roleService")
public class RoleService extends BaseService {

	@SuppressWarnings("unchecked")
	public List<Role> getRolesInfo(Role role) throws Exception{
		return (List<Role>)this.getDaoSupport().findForList("T_Role.getRolesInfo", role);
	}

	@SuppressWarnings("unchecked")
	public List<Role> getRole(Role role) throws Exception{
		return (List<Role>)this.getDaoSupport().findForList("T_Role.getRole", role);
	}
	
	@SuppressWarnings("unchecked")
	public List<Role> getRolePage(Role role, Page page) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
    	map.put("info", role);
		map.put("page", page);
		return (List<Role>)this.getDaoSupport().findForList("T_Role.getRolePage", map);
	}

	public Role getRoleInfo(UserRole userRole) throws Exception{
		return (Role)this.getDaoSupport().findForObject("T_Role.getRoleInfo", userRole);
	}


	public int saveRole(Role role) throws Exception {
	    return (int) this.getDaoSupport().save("T_Role.insertRole", role);
	}

	public int updateRole(Role role) throws Exception {
	   return (int) this.getDaoSupport().update("T_Role.updateRole", role);
	}

	public int deleteRole(Role role) throws Exception {
	   return (int) this.getDaoSupport().delete("T_Role.deleteRole", role);
	}

}
